local jiaoxing = fk.CreateSkill {
  name = "lingling__jiaoxing",
}

Fk:loadTranslationTable{
  ["lingling__jiaoxing"] = "骄行",
  [":lingling__jiaoxing"] = "当你使用【杀】指定目标后，或成为其他角色使用【杀】的目标后，你可以摸一张牌使之无法抵消，然后受到伤害的角色"..
  "可以将一张【闪】当【无中生有】使用。",

  ["#lingling__jiaoxing-invoke"] = "骄行：你可以摸一张牌令此【杀】无法抵消，受到伤害的角色可以将【闪】当【无中生有】使用",
  ["#lingling__jiaoxing-ex_nihilo"] = "骄行：你可以将一张【闪】当【无中生有】使用",
}

local spec = {
  on_cost = function (self, event, target, player, data)
    local room = player.room
    if room:askToSkillInvoke(player, {
      skill_name = jiaoxing.name,
      prompt = "#lingling__jiaoxing-invoke",
    }) then
      event:setCostData(self, {tos = data.use.tos})
      return true
    end
  end,
  on_use = function (self, event, target, player, data)
    player:drawCards(1,jiaoxing.name)
    data.use.unoffsetableList = table.simpleClone(player.room.players)
    data.extra_data = data.extra_data or {}
    data.extra_data.lingling__jiaoxing = true
  end,
}

jiaoxing:addEffect(fk.TargetSpecified, {
  anim_type = "offensive",
  can_trigger = function (self, event, target, player, data)
    return target == player and player:hasSkill(jiaoxing.name) and
      data.card.trueName == "slash" and data.firstTarget
  end,
  on_cost = spec.on_cost,
  on_use = spec.on_use,
})

jiaoxing:addEffect(fk.TargetConfirmed, {
  anim_type = "masochism",
  can_trigger = function (self, event, target, player, data)
    return target == player and player:hasSkill(jiaoxing.name) and
      data.card.trueName == "slash"
  end,
  on_cost = spec.on_cost,
  on_use = spec.on_use,
})

jiaoxing:addEffect(fk.CardUseFinished, {
  mute = true,
  is_delay_effect = true,
  can_trigger = function (self, event, target, player, data)
    return not player.dead and data.damageDealt and data.damageDealt[player] and
      data.extra_data and data.extra_data.lingling__jiaoxing and
      #player:getHandlyIds() > 0 and player:canUse(Fk:cloneCard("ex_nihilo"))
  end,
  on_use = function (self, event, target, player, data)
    player.room:askToUseVirtualCard(player, {
      name = "ex_nihilo",
      skill_name = jiaoxing.name,
      prompt = "#lingling__jiaoxing-ex_nihilo",
      cancelable = true,
      card_filter = {
        n = 1,
        pattern = "jink",
      },
    })
  end,
})

--[[jiaoxing:addEffect(fk.BeforeDrawCard, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(jiaoxing.name) and data.skillName == "ex_nihilo_skill"
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    data.num = data.num + 1
  end,
})]]--

return jiaoxing
